<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <div class="navbar navbar-default" id="navbar">
    <script type="text/javascript">
        try{ace.settings.check('navbar' , 'fixed')}catch(e){}
    </script>

    <div class="navbar-container" id="navbar-container">
        <div class="navbar-header pull-left">
            <a href="index.jsp" class="navbar-brand">
                <small>
                    <i class="icon-leaf"></i>
                   Blue Field
                </small>
            </a><!-- /.brand -->
        </div><!-- /.navbar-header -->

        <div class="navbar-header pull-right" role="navigation">
            <ul class="nav ace-nav">
            
            <li class="purple">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                        <i class="icon-calendar"></i>
                        <div class="user-info">
						      <small>已连续签到</small>
							  <font id="sign_days">0</font>天
						</div>
                    </a>
                </li>
            
                <li class="info">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                        <i class="icon-bookmark"></i>
                        <div class="user-info">
						      <small>等级</small>
							  <font id="user_level">0</font>级
						</div>
                    </a>
                </li>
               
                    
                <li class="green">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                        <i class="icon-envelope icon-animated-vertical"></i>
                       <div class="user-info">
						      <small>新消息</small>
							  <font>${questionnaire_count}</font>条
						</div>
                    </a>

                    <ul class="pull-right dropdown-navbar dropdown-menu dropdown-caret dropdown-close">
                        <li class="dropdown-header">
                            <i class="icon-envelope-alt"></i>
                            ${questionnaire_count}条消息
                        </li>
<c:forEach items="${questionnaires}" var="questionnaire" varStatus="status" end="7">
                        <li>
                            <a href="Questionnaire_view?questionnaire_id=${questionnaire.questionnaire_id}">
										<span class="msg-body">
											<span class="msg-title">
												<span class="blue">系统信息:</span>
												${questionnaire.questionnaire_theme}
											</span>

											<span class="msg-time">
												<i class="icon-time"></i>
												<span>${questionnaire.questionnaire_date}</span>
											</span>
										</span>
                            </a>
                        </li>
</c:forEach>
                        <li>
                            <a href="questionnaires.jsp">
                                查看所有消息
                                <i class="icon-arrow-right"></i>
                            </a>
                        </li>
                    </ul>
                </li>

                <li class="light-blue">
                    <a data-toggle="dropdown" href="#" class="dropdown-toggle">
                        <img class="nav-user-photo" src="assets/avatars/user.jpg" alt="photo" />
								<span class="user-info">
									<small>欢迎光临,</small>
								
								</span>

                        <i class="icon-caret-down"></i>
                    </a>

                    <ul class="user-menu pull-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
                        <li>
                            <a href="account-safe.jsp">
                                <i class="icon-cog"></i>
                                设置
                            </a>
                        </li>

                        <li>
                            <a href="profile.jsp">
                                <i class="icon-user"></i>
                                个人资料
                            </a>
                        </li>

                        <li class="divider"></li>

                        <li id="sign_out">
                            <a href="#">
                                <i class="icon-off"></i>
                                退出
                            </a>
                        </li>
                    </ul>
                </li>
            </ul><!-- /.ace-nav -->
        </div><!-- /.navbar-header -->
    </div><!-- /.container -->
</div>
<script src="js/jquery.min.js"></script>
<script>
$(function(){    //导航栏用户信息获取

	$.get("User_jurisdiction_servlet",function(data,status){
		if(data.result){
			
			$("span[class='user-info']").html("<small>欢迎光临,</small>"+data.nickname);
			if(data.user_photo_path!=""&&data.user_photo_path!=null){
				$("img[class='nav-user-photo']")[0].src=data.user_photo_path;
			}else{
				$("img[class='nav-user-photo']")[0].src="images/no_photo.jpg";
			}
		}
	},
	"json"
	);
});

$(function(){
	$("#sign_out").click(function(){
		$.get("Sign_out",function(data,status){
			if(data.result==true){
			window.location.href="index.jsp";	
			}else{
				alert("退出失败");
			}
		},"json");
	});
});

$(function(){
	var $sign_days = $("#sign_days");
	var $user_level = $("#user_level");
	//用户等级
	$.get("User_data",function(data,status){
		if(data.result == true){
			$user_level.html(data.user_level);
		}else{
			$user_level.html("获取数据失败");
		}
	},"json");
	
	//用户签到天数
	$.get("User_sign_days",function(data,status){
		if(data.result == true){
			$sign_days.html(data.sign_days);
		}else{
			$sign_days.html("获取数据失败");
		}
	},"json");
	
});



</script>